import { reqAddressInfo, reqOrderInfo } from '@/api';
const state = {
    addressInfo: [],
    orderInfo: {},
};
const mutations = {
    GETADDRESSINFO(state, addressInfo) {
        state.addressInfo = addressInfo;
    },
    GETORDERINFO(state, orderInfo) {
        state.orderInfo = orderInfo;
    }
};
const actions = {
    async getAddressInfo(context) {
        let result = await reqAddressInfo();
        if (result.code == 200) {
            context.commit('GETADDRESSINFO', result.data);
            return 'ok'
        } else {
            return Promise.reject(new Error('获取地址信息失败'))
        }
    },
    async getOrderInfo(context) {
        let result = await reqOrderInfo();
        if (result.code == 200) {
            context.commit('GETORDERINFO', result.data)
            return 'ok'
        } else {
            return Promise.reject(new Error('获取商品清单失败'))
        }
    }
};
const getters = {};

export default {
    state,
    mutations,
    actions,
    getters,
}